package com.ruoyi.framework.config;

import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;

public class CustomLettuceConnectionFactory extends LettuceConnectionFactory {

    public CustomLettuceConnectionFactory(RedisStandaloneConfiguration standaloneConfig, LettuceClientConfiguration clientConfig) {
        super(standaloneConfig,clientConfig);
    }

    @Override
    public RedisConnection getConnection() {
        RedisConnection connection = super.getConnection();
        if (connection == null || connection.isClosed()) {
            resetConnection();
            //connection = super.getRedisConnection();
            connection = super.getConnection();
        }
        return connection;
    }
}
